/**
 * 时间格式转换
 * @param {时间字符串} dataStr
 * @param {时间格式} patten
 */
const formatDate = function (dataStr, patten = '') {
  var bt = new Date(dataStr)
  var y = bt.getFullYear()
  var m = (bt.getMonth() + 1).toString().padStart(2, '0')
  var d = bt.getDate().toString().padStart(2, '0')
  var hh = bt.getHours().toString().padStart(2, '0')
  var mm = bt.getMinutes().toString().padStart(2, '0')
  var ss = bt.getSeconds().toString().padStart(2, '0')
  if (patten.toLowerCase() === 'yyyy-mm-dd') {
    return `${y}-${m}-${d}`
  } else {
    return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
  }
}
export default formatDate
